#include <cstdio>
int binary_search(int a[], int left, int right, int t)
{
    int mid = (left + right) / 2;
    if (t == a[mid])
        return mid;
    else if (t < a[mid])
        return binary_search(a, left, mid - 1, t);
    else
        return binary_search(a, mid + 1, right, t);
}
int main()
{
    int a[] = {1, 3, 4, 7, 8, 9, 10, 12};
    int index = binary_search(a, 0, sizeof(a) / sizeof(int) - 1, 9);
    printf("index=%d\n", index);
}